package metier;

import java.sql.Date;
import java.util.HashMap;

public class Catalogue
{
	private int annee;
	private Date dateDebut,dateFin;
	private HashMap<Jouet,Integer> lesJouetsProposes;
	
	public Catalogue(int annee, Date dateDebut, Date dateFin)
	{
		super();
		this.annee = annee;
		this.dateDebut = dateDebut;
		this.dateFin = dateFin;
		this.lesJouetsProposes = new HashMap<Jouet,Integer>();
	}
	

	public int getAnnee()
	{
		return annee;
	}

	public Date getDateDebut()
	{
		return dateDebut;
	}

	public Date getDateFin()
	{
		return dateFin;
	}
	
	public int quantiteProposee()
	{
		int total;
		total =0;
		
		for(Integer laQuantite: this.lesJouetsProposes.values())
		{
			total = total + laQuantite;
		}
		return total;
	}
	
	public void ajouterJouet(Jouet j,int qte)
	{
		this.lesJouetsProposes.put(j, qte);
	}
	
	public HashMap<Categorie,Integer> statsCateg()
	{
		HashMap<Categorie,Integer> lesCategs;
		lesCategs = new HashMap<Categorie,Integer>();
		Categorie laCateg;
		int quantite;
		
		for (Jouet leJouet : this.lesJouetsProposes.keySet())
		{
			laCateg = leJouet.getLaCateg();
			quantite = this.lesJouetsProposes.get(leJouet);
			if (lesCategs.containsKey(laCateg))
			{
				quantite = quantite + lesCategs.get(laCateg);
			}
			lesCategs.put(laCateg, quantite);
		}
			
			
		return lesCategs;
		
	}
	 
	public String toString()
	{
		String description;
		description = ("annee=" + this.annee + ", dateDebut=["+this.dateDebut+"], dateFin=["+this.dateFin+"]");
		return description;
	}
	
}
